package com.wyz.tracing.domain.entity.tracing.different;

import com.wyz.tracing.domain.entity.base.Aggregate;
import com.wyz.tracing.domain.entity.base.Identifier;
import com.wyz.tracing.domain.entity.tracing.different.field.FieldDifference;
import com.wyz.tracing.enums.DifferenceType;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wyz
 * @version 1.0
 * @date 2023/4/20
 * <p>
 * 聚合的差异
 */
@Getter
@Setter
public class AggregateDifference<T extends Aggregate<ID>, ID extends Identifier> {

    /**
     * 快照对象
     */
    private T snapshot;

    /**
     * 追踪对象
     */
    private T aggregate;

    /**
     * 差异类型
     * 标记整个聚合的差异类型
     */
    private DifferenceType differentType;

    /**
     * 差异
     * 字段级
     */
    private Map<String, FieldDifference> fieldDifferences;

    public AggregateDifference(T snapshot, T aggregate, DifferenceType differentType) {
        this.snapshot = snapshot;
        this.aggregate = aggregate;
        this.differentType = differentType;
        this.fieldDifferences = new HashMap<>();
    }
}
